package com.reins.bookstore.object;

import java.math.BigDecimal;

import com.reins.bookstore.entity.Book;
import lombok.Data;

@Data
public class BasketlineDTO {
    private int bookId;

    private String name;
    private String author;
    private BigDecimal price;
    private Integer num;
    private BigDecimal total;

    public BasketlineDTO(int bookId, String name, String author, BigDecimal price, Integer num){
        this.bookId = bookId;
        this.name = name;
        this.author = author;
        this.price = price;
        this.num = num;
        BigDecimal tmp_num = new BigDecimal(this.num);
        this.total = price.multiply(tmp_num);
    }
    public BasketlineDTO(Book book, int num){
        this.bookId = book.getBookId();
        this.name = book.getName();
        this.author = book.getAuthor();
        this.price = book.getPrice();
        this.num = num;
        BigDecimal tmp_num = new BigDecimal(this.num);
        this.total = this.price.multiply(tmp_num);
    }
    public BasketlineDTO() {
    }
}
